%Advanced Vision Assignment III
%*****************************************************
clear all
clc;
%Set flags
displayRgbImage = true;
imageProcessing  =false;
debugRun  =false;

%Transform the data
%transformData('./bindermat/','./bindermat/transform/')

if ~debugRun
%Load the tranformed data
[output_args] = loadTransformedData('./bindermat/transform/','../field.jpg','../frameGrabs/');
else
%load transformed data
xyzrgbStruct = load('bindermat/transform/rgb_xyz_frame_15');

%load from the transformed 
rgbImage = xyzrgbStruct.rgbImage;
xyzImage = xyzrgbStruct.xyzImage;

%Determine if there is a briefcase in the image
%**************************************************************
%Process the range values to find the image
imageZ = xyzImage(:,:,3);

%Find the closest point in the image, rows, cols
[row, col] = find(imageZ == max(imageZ(imageZ<0)));

%Find the closest point in the image
closestPoint = imageZ(row(1),col(1));

if closestPoint> -1.8
%Find the briefcase corner points and the plane
[corners, plane] = findBriefcase(rgbImage, xyzImage, closestPoint,0);
end
%**************************************************************

end

